<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="username">
    <input type="text" id="password">
    <form action="服务器地址" id="myForm" onsubmit="submitHandle">
        <input type="text" name="username">
        <button id="resetbtn">重置</button>
        <button>提交</button>
    </form>
    <script>

         var username = document.getElementById("username")
         var password = document.getElementById("password")
         //input事件
         username.oninput = function(e){
            console.log(e.target.value);//读取数据
         }
         //select事件
         username.onselect = function(){
            console.log("选中了");
         }

         //Change事件:失去焦点或者回车的时候触发
         password.onchange = function(e){
            console.log(e.target.value);
         }

         //reset事件
         var resetbtn = document.getElementById("resetbtn");
         var myForm = document.getElementById("myForm");
         resetbtn.onreset = function(){
            //myform调用reset方法
             myForm.reset();//触发在表单上：清空表单
         }

         //submit事件
         function submitHandle(){
            console.log("提交成功");
         }

    </script>
    
</body>
</html>